package solution;

/**
 * @author : wenchao.long
 * @date : Created in 2024-07-02 下午 10:46 周二
 * @description :
 * 		<a href="https://leetcode.cn/problems/sum-of-two-integers/description/">两整数之和</a>
 */
public class No371 {

	public static int getSum(int a, int b) {
		int carry;
		// 假设a = 3, b = 5
		// a = 0011  b = 0101 => a & b = 0001, a ^ b = 0101
		while (b != 0) {
			carry = (a & b) << 1;
			a = a ^ b;
			b = carry;
		}
		return a;
	}

	public static void main(String[] args) {
		int sum = getSum(3, 5);
		System.out.println(sum);
	}
}
